package com.handu.luna.core.domain.order;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.handu.luna.core.domain.BaseRepository;

public interface OrderDetailRepository extends JpaRepository<OrderDetail, Long> ,BaseRepository<OrderDetail> , JpaSpecificationExecutor<OrderDetail>{
	
	
	@Query("select o from OrderDetail o order by createdDate desc  ")
	Page<OrderDetail> findAll(Pageable pageable);
	
	/**
	 * 根据子订单的单号进行查找
	 * @param orderNumber 子订单单号
	 * @return
	 */
	@Query("select o from OrderDetail o where orderNumber = :orderNumber")
	List<OrderDetail> findByOrderNumber(@Param("orderNumber")String orderNumber);
}
